﻿using CuoiHoi.Business;
using CuoiHoi.Entities;
using System;
using System.Web.Routing;
using System.Web.UI;

namespace CuoiHoi
{
    public partial class DanhMuc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            //{
                //Lay tieu de, mo ta tu khoa cho trang
                string IdDanhMuc = "0";
                if (RouteData.Values["IdDanhMuc"] != null)
                    IdDanhMuc = RouteData.Values["IdDanhMuc"].ToString();
                else
                    if (RouteData.Values["IdInfo"] != null)
                        IdDanhMuc = RouteData.Values["IdInfo"].ToString();
                    else
                        if (RouteData.Values["TitleMedia"] != null)
                            IdDanhMuc = RouteData.Values["IdMedia"].ToString();

                ETheLoai theloai = BTheLoai.SelectByID(int.Parse(IdDanhMuc));
                if (theloai.Title != null)
                {
                    Page.Title = theloai.Title;
                    Page.MetaDescription = theloai.Description;
                    Page.MetaKeywords = theloai.Keyword;
                }
                // Kiem tra loai trang
                PlaceHolder1.Controls.Clear();
                if (RouteData.Values["Id"] != null && RouteData.Values["Title"] != null)
                    PlaceHolder1.Controls.Add(LoadControl("~/UserControls/ChiTietDanhMuc.ascx"));
                else if (RouteData.Values["IdItemMedia"] != null)
                    PlaceHolder1.Controls.Add(LoadControl("~/UserControls/ChiTietMedia.ascx"));
                else if (RouteData.Values["IdDanhMuc"] != null)
                    PlaceHolder1.Controls.Add(LoadControl("~/UserControls/DanhMuc.ascx"));
                else if (RouteData.Values["IdInfo"] != null)
                    PlaceHolder1.Controls.Add(LoadControl("~/UserControls/ThongTin.ascx"));
                else if (RouteData.Values["IdMedia"] != null)
                    PlaceHolder1.Controls.Add(LoadControl("~/UserControls/Media.ascx"));
            //}
            //catch
            //{
            //    Response.Write("error");
            //}
        }
    }
}